package lambda;

import lambda.i.*;

/**
 * @author LIBOFEI
 * @ClassName LambdaTest
 * @description
 * @date 2020/10/9 13:46
 * @Version 1.0
 **/
public class LambdaTest {

    public static void main(String[] args) {

        //1.7之前版本，匿名内部类
        NoReturnNoParam noReturnNoParam = new NoReturnNoParam() {
            @Override
            public void method() {
                System.out.println("noReturnNoParam--By-1.7");
            }
        };
        noReturnNoParam.method();

        //无参无返回
        NoReturnNoParam noReturnNoParamL = () -> {
           System.out.println("noReturnNoParam--By--1.8");
        };
        noReturnNoParamL.method();

        //一个参数无返回
        NoReturnOneParam  noReturnOneParam = (int a) ->{
           System.out.println("NoReturnOneParam param:" + a);
        };
        noReturnOneParam.method(4);

        //多个参数无返回
        NoReturnMultiParam noReturnMultiParam = (int a, int b) -> {
            System.out.println("NoReturnMultiParam param:" + "{" + a +"," + + b +"}");
        };
        noReturnMultiParam.method(6, 8);

        //无参有返回值
        ReturnNoParam returnNoParam = () -> {
            System.out.print("ReturnNoParam");
            return 1;
        };

        int res = returnNoParam.method();
        System.out.println("return:" + res);


        //一个参数有返回值
        ReturnOneParam returnOneParam = (int a) -> {
            System.out.println("ReturnOneParam param:" + a);
            return 1;
        };

        int res2 = returnOneParam.method(6);
        System.out.println("return:" + res2);

        //多个参数有返回值
        ReturnMultiParam returnMultiParam = (int a, int b) -> {
            System.out.println("ReturnMultiParam param:" + "{" + a + "," + b +"}");
            return 1;
        };

        int res3 = returnMultiParam.method(6, 8);
        System.out.println("return:" + res3);
    }
}
